package cc.mrbird.febs.power.controller;


import cc.mrbird.febs.common.utils.R;
import cc.mrbird.febs.power.entity.RoleBindAppInfo;
import cc.mrbird.febs.power.service.IRoleBindAppInfoService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author MrBird
 */
@RestController
@RequestMapping("/power/role-bind-app-info")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class RoleBindAppInfoController {

    private final IRoleBindAppInfoService iRoleBindAppInfoService;

    /**
     * 根据appId获取角色信息
     * @param roleId
     * @return
     */
    @GetMapping("/info/{roleId}")
    public R getRoleInfoByAppId(@PathVariable("roleId") Integer roleId) {
        return R.ok(iRoleBindAppInfoService.getRoleInfoByAppId(roleId));
    }

    /**
     * 新增角色绑定应用
     * @param roleBindAppInfo
     * @return
     */
    @PostMapping("/RoleBindAppInfoAdd")
    public R RoleBindAppInfoAdd(RoleBindAppInfo roleBindAppInfo) {
        return R.ok(iRoleBindAppInfoService.save(roleBindAppInfo));
    }

    /**
     * 修改角色绑定应用
     * @param roleBindAppInfo
     * @return
     */
    @PutMapping("/RoleBindAppInfoEdit")
    public R RoleBindAppInfoEdit(RoleBindAppInfo roleBindAppInfo) {
        return R.ok(iRoleBindAppInfoService.updateById(roleBindAppInfo));
    }

    /**
     * 通过ID删除记录
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")
    public R RoleBindAppInfoDel(@PathVariable Integer id) {
        return R.ok(iRoleBindAppInfoService.removeById(id));
    }

}
